home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / k3bintvalidator.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-05-27  |  2.0 KB  |  85 lines

  1. /* 
  2.  *
  3.  * $Id: k3bintvalidator.h 619556 2007-01-03 17:38:12Z trueg $
  4.  * Copyright (C) 2004 Sebastian Trueg <trueg@k3b.org>
  5.  *
  6.  * This file is part of the K3b project.
  7.  * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  * See the file "COPYING" for the exact licensing terms.
  14.  */
  15.  
  16.  
  17. #ifndef _K3B_INT_VALIDATOR_H_
  18. #define _K3B_INT_VALIDATOR_H_
  19.  
  20. #include <qvalidator.h>
  21. #include "k3b_export.h"
  22. class QWidget;
  23. class QString;
  24.  
  25. /**
  26.  * QValidator for integers.
  27.  *
  28.  * It differs from QIntValidator and KIntValidator in the fact that
  29.  * it also accepts hex numbers prefixed with 0x.
  30.  */
  31. class LIBK3B_EXPORT K3bIntValidator : public QValidator
  32. {
  33.  public:
  34.   /**
  35.    * Constuctor.  Also sets the base value.
  36.    */
  37.   K3bIntValidator ( QWidget * parent, const char * name = 0 );
  38.  
  39.   /**
  40.    * Constructor.  Also sets the minimum, maximum, and numeric base values.
  41.    */
  42.   K3bIntValidator ( int bottom, int top, QWidget * parent, const char * name = 0 );
  43.  
  44.   /**
  45.    * Destructs the validator.
  46.    */
  47.   virtual ~K3bIntValidator ();
  48.  
  49.   /**
  50.    * Validates the text, and return the result.  Does not modify the parameters.
  51.    */
  52.   virtual State validate ( QString &, int & ) const;
  53.  
  54.   /**
  55.    * Fixes the text if possible, providing a valid string.  The parameter may be modified.
  56.    */
  57.   virtual void fixup ( QString & ) const;
  58.  
  59.   /**
  60.    * Sets the minimum and maximum values allowed.
  61.    */
  62.   virtual void setRange ( int bottom, int top );
  63.  
  64.   /**
  65.    * Returns the current minimum value allowed.
  66.    */
  67.   virtual int bottom () const;
  68.  
  69.   /**
  70.    * Returns the current maximum value allowed.
  71.    */
  72.   virtual int top () const;
  73.  
  74.   /**
  75.    * If the string starts with 0x it's assumed to be a hex number.
  76.    */
  77.   static int toInt( const QString&, bool* ok = 0 );
  78.  
  79.  private:
  80.   int m_min;
  81.   int m_max;
  82. };
  83.  
  84. #endif
  85.